/*
   CLCore.h

   Created by Miroslav Karpis on 1/12/11.
   Copyright 2011 Miroslav Karpis. All rights reserved.

   This file is part of molecEvol.

   molecEvol is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   Foobar is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CLCORE_H
#define CLCORE_H

#include <OpenCL/opencl.h>

#include <iostream>
#include <fstream>
#include <sstream>

#ifdef __APPLE__

#include <OpenCL/cl.h>
#include <OpenCL/cl_gl.h>
#include <OpenCL/cl_gl_ext.h>
#include <OpenCL/cl_ext.h>

#else

#include <CL/cl.h>
#include <CL/cl_gl.h>
#include <CL/cl_gl_ext.h>
#include <CL/cl_ext.h>

#endif

using namespace std;

class CLCore
{
public:
    CLCore();

protected:
    //! gets and prints available platforms/devices
    bool getHostDeviceInfo();

    //! will create context - if GPU is not available we create context on CPU
    cl_context createContext();

    cl_program CreateProgram(cl_context context,
                             cl_device_id device,
                             const char* fileName);

    cl_uint num_platforms;
    cl_platform_id* clPlatformIDs;
    cl_device_id *devicesIDs;

private:
    cl_int errCode;
};

#endif // CLCORE_H
